package cn.edu.hdu.worktbench;

public class ProxyComponent implements Component{
    private RealComponent realName;
    private String  name;
    public ProxyComponent(String name){
        this.name=name;
    }
    @Override
    public void display() {
        if(realName == null){
            realName =new RealComponent(name);
        }
        realName.display();
    }

    @Override
    public void addComponent() {
        if(realName == null){
            realName =new RealComponent(name);
        }
        realName.addComponent();

    }

    @Override
    public void deleteComponent() {
        if(realName == null){
            realName =new RealComponent(name);
        }
        realName.deleteComponent();
    }
}
